package com.shane.air.MakeDirectoryList
{
	
	// this is only going to work in air
	// returns an array of files
	
	import flash.display.Sprite;
	import flash.events.*;
	
	public class MakeDirectoryList extends Sprite
	{
		import flash.filesystem.*;
		import com.FPSCounter.*;
		
		//var appDir:File = File.applicationDirectory;
		var appDir:File = File.documentsDirectory;
		var targetDir:File = new File(); 
		var dirList:Array;
		public function MakeDirectoryList() 
		{
		}
		public function init ($path:String):Array {
			try {
				targetDir = appDir.resolvePath($path);
			} catch (e:Error) {
				trace("Bad Path");
			}
			
			if(targetDir.isDirectory){  
			//	showDirectory(targetDir);
				dirList = targetDir.getDirectoryListing();
			} else {
				dirList = null;
				trace(targetDir+" is not a folder — no joy");
			}
			return(dirList);
		}

           /* private function showDirectory($fileRef:File):void {   
                var dirlist:Array = $fileRef.getDirectoryListing();  
                
                //displayFiles(dirlist);  
            }  
            private function displayFiles(files:Array):Array{  
               //clear the output   
                out.text = "";  
                                 // loop the array of files and display them  
               for each(var file:File in files) {  
               	                   //  if(file.isDirectory){  
                        		 out.appendText( file.name + "\n");                     
                    //}  
                 }  
             } */
	}
}